package com.welsy.authoring.command
{
	import com.adobe.cairngorm.commands.ICommand;
	import com.adobe.cairngorm.control.CairngormEvent;
	import com.welsy.authoring.business.*;
	import com.welsy.authoring.event.RemoveCourseEvent;
	import com.welsy.authoring.vo.*;
	
	import mx.controls.Alert;
	import mx.rpc.IResponder;
	import mx.rpc.events.FaultEvent;	
	
	/**
	  * The command for course retrieval
	  * @author Welsy.org
 	  * @version	$Revision: 1.1 $
	  */
	public class RemoveCourseCommand implements ICommand, IResponder
	{
	  	public function RemoveCourseCommand()
		{	 
		}
	
		/**
		  * Set up the command, starting the chain with the delegate call
		  * @param event The event which triggers the call chain
		  */
		public function execute( event : CairngormEvent ): void
		{
			var removeCourseEvent:RemoveCourseEvent = RemoveCourseEvent( event );
			
			var delegate : RemoveCourseDelegate = new RemoveCourseDelegate( this );
			delegate.removeCourseComponents(removeCourseEvent.courseId);
		}
	
		/**
		  * Evaluate the SOAP result
		  * @param event The SOAP server result
		  */
		public function result( event : Object ) : void
		{			
			// TODO - dunno what to expect
		}
	
		/**
		  * The fault handler
		  * Report a simple error message to the user
		  * @param The failure event
		  */
		public function fault( event : Object ) : void
		{
			var faultEvent : FaultEvent = FaultEvent( event );
			Alert.show( "Course could not be retrieved!" );
		}
	}

}